package cn.songtx.iot.pojo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class Result {

    /*
     * 统一的响应结果
     * 3个静态方法
     * 有数据的成功,无数据的成功,有信息的失败
     * */
    private Integer code;
    private String msg;
    private Object data;

    public static Result success(Object data) {
        return new Result(200, "success", data);
    }

    public static Result success() {
        return new Result(200, "success", null);
    }

    public static Result error(String msg) {
        return new Result(0, msg, null);
    }
}
